<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

/**
 * App\Models\MettingHotel
 *
 * @property int $id 主键
 * @property string|null $title 酒店名称
 * @property string|null $tel 服务电话
 * @property string $image 酒店图片
 * @property float|null $lng 坐标经度
 * @property float|null $lat 坐标纬度
 * @property string|null $content 酒店介绍
 * @property array|null $images 酒店图集
 * @property \Illuminate\Support\Carbon|null $created_at
 * @property \Illuminate\Support\Carbon|null $updated_at
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\MeetingHotel newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\MeetingHotel newQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\MeetingHotel query()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\MeetingHotel whereContent($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\MeetingHotel whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\MeetingHotel whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\MeetingHotel whereImage($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\MeetingHotel whereImages($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\MeetingHotel whereLat($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\MeetingHotel whereLng($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\MeetingHotel whereTel($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\MeetingHotel whereTitle($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\MeetingHotel whereUpdatedAt($value)
 * @mixin \Eloquent
 */
class MeetingHotel extends Model
{
    protected $table = 'meeting_hotel';
    protected $primaryKey = 'id';
    protected $fillable = ['title', 'image', 'lng', 'lat', 'content', 'images', 'tel'];
    protected $casts = [
        'images' => 'array'
    ];

    /**
     * @param $value
     * @return string
     */
    public function getImageAttribute($value)
    {
        return $value ? image_url($value) : $value;
    }

    /**
     * @param $value
     */
    public function setImageAttribute($value)
    {
        $this->attributes['image'] = strip_image_url($value);
    }
}
